package com.wh.sftp;

import org.apache.log4j.Logger;

public class Demo {
    private static Logger log = Logger.getLogger(SFTPUtil.class);

    public static void main(String[] args) throws Exception {
        String username = "sftp";
        String password = "2020@newImage";
        String host = "49.232.18.205";
        int port = 22;
        String hostDir = "/upload";
        SFTPUtil sftpUtil = new SFTPUtil(username, password, host, port, hostDir);
        try {
            sftpUtil.login();
        } catch (Exception e) {
            //  sftpUtil.isExist("/nfs/image/"+"a","ca30e214be8243eea7de9be8f015d807.jpg");
            //  String s = "F:/新华/222/3/4/";
            //  String[] dirs = s.split("/");
            //  File file = new File("F:/新华/222/3/4/44");
            //  if (!file.exists()) {
            //      file.mkdirs();
            //  }
            String newPath = "/upload/69/88";
            //递归在sftp服务器上上传文件--ThreadLocal
            //sftpUtil.mkdirDirs(newPath);
            //sftpUtil.mkdirDir(dirs, tempPath, dirs.length, index);
            sftpUtil.upload("/upload/668/88", "F:\\新华\\11.jpg");
            //sftpUtil.download("/nfs/image/applet/img/2021/05/21/idimg", "4d1ad761b55847c4a023c4ffed422fc5.jpg", "F:/新华/222/3/4/44");
        } finally {
            sftpUtil.logout();
        }
    }
}
